package com.bookRecommend.mapper;

import com.bookRecommend.model.Score;
import com.bookRecommend.provider.ScoreProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Administrator
 * @description 针对表【score(评分记录表)】的数据库操作Mapper
 * @createDate 2022-07-20 21:59:11
 * @Entity .Score
 */
public interface IScoreMapper {
    @Select("select score.*, user.username, book.bookname, book.author from score join user on (user.id = score.userid) join book on (book.id = score.bookid)")
    List<Score> selectAllScores();

    @SelectProvider(ScoreProvider.class)
    List<Score> selectByScore(Score score);

    @InsertProvider(ScoreProvider.class)
    int insertScore(Score score);

    @UpdateProvider(ScoreProvider.class)
    int updateScore(Score score);

    @DeleteProvider(ScoreProvider.class)
    int deleteScore(Score score);

    @Delete("delete from score where id = #{id}")
    int deleteById(Integer id);

    @Select("select * from score where userid = #{userId} order by score limit 0, 1")
    Score selectHotScoreByUserId(Integer userId);

}




